

#include<vector>

namespace bit
{
	template<class T, class Container = vector<T>>
	class priority
	{
	public:


		void AdjustUp(int child)
		{
			int parent = (child - 1) / 2;
			while (child > 0)
			{
				if (_con[parent] < _con[child])
				{
					swap(_con[parent], _con[child]);
					child = parent;
					parent = (child - 1) / 2;
				}
				else
				{
					break;
				}
			}

		}


		/*	void AdjustUp(int parent)
			{
				int child = parent * 2 + 1;
				while (child < _con.size())
				{
					if ( child +1 < _con.size() && con[child + 1] < con[child])
					{
						++child;
					}

					if (con[child] < con[parent])
					{
						swap(con[child], con[parent]);
						parent = child;
						child = parent * 2 + 1;
					}
					else
					{
						break;
					}
				 }

			}*/
		void AdjustUp(int parent)
		{
			int child = parent * 2 + 1;
			while (_con[child] < _con.size())
			{
				if (_con[child + 1] < _con[child] && _con[child + 1] < _con.size())
				{
					++child;
				}

				if (_con[parent] > _con[child])
				{
					swap(_con[parent], _con[child]);
					parent = child;
					child = parent * 2 + 1;
				}

				else {
					break;
				}
			}

		}

		void push(const  T& x)
		{
			_con.push_back(x);
			AdjustUp(_con.size() - 1);
		}


	private:
		Container _con;
	};
}